<template>
  <div class="zll">
    <div class="zll1">
      <span style="font-size: 12px; color: #b3b3b3; width: 50px" class="xTXZ">
        <el-dropdown trigger="click">
          <span
            class="el-dropdown-link"
            @click="hGetReleaseAll"
            ref="dropdown111"
          >
            系统选择<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown" id="dropdown" class="cjycjy">
            <div class="hezione" @click.native.prevent>
              <el-checkbox
                v-model="item.isChecked"
                v-for="item in allList"
                :key="item.id"
              >
                <div @click.prevent>
                  <!-- <img src="../photos/icon-rongzix.svg" alt="" @click.prevent /> -->
                  <span @click.prevent style="width: 200px" class="aaa">{{
                    item.name
                  }}</span>
                </div>
              </el-checkbox>
              <div class="btn">
                <el-button type="primary" class="sure" @click="hSureEdit"
                  >确认</el-button
                >
                <el-button class="cancel" @click="$refs.dropdown111.click()"
                  >取消</el-button
                >
              </div>
            </div>
          </el-dropdown-menu>
        </el-dropdown>
      </span>
    </div>
  </div>
</template>



<script>
export default {
  data() {
    return {
      allList: [], //所有线上系统
      systemIds: [], //用户新勾选系统
    };
  },
  methods: {
    hGetReleaseAll() {
      // let userId = JSON.parse(sessionStorage.getItem("user")).id;
      // console.log(userId);
      // this.$api("selectReleaseAllByAccountId", { params: { id: userId } }).then(
      //   (res) => {
      //     if (res && res.data.state == "success") {
      //       this.allList = res.data.data;
      //     }
      //   }
      // );
    },

    // 确认修改功能
    hSureEdit() {
      let arr = this.allList.map(function (item) {
        if (item.isChecked === true) {
          return item.id;
        }
      });
      this.systemIds = arr.filter((item) => {
        return item;
      });
      console.log(this.systemIds);
      let params = {
        userId: JSON.parse(sessionStorage.getItem("user")).id,
        systemIds: this.systemIds,
      };
      this.$api("selectdEdit", { params }).then((res) => {
        if (res && res.data.success) {
          this.$refs.dropdown111.click();
          this.$popSuccess(res.data.message);
        } else {
          this.$popError(res.data.message);
        }
      });
    },
  },
};
</script>


<style>
</style>

